﻿using Efcore_Test.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Efcore_Test.Data.config
{
    public class OrgUnitConfig : IEntityTypeConfiguration<OrgUnit>
    {
        public void Configure(EntityTypeBuilder<OrgUnit> builder)
        {
            builder.ToTable("T_OrgUnit");
            builder.HasOne(x => x.Parent).WithMany(x => x.Children); //根节点可能为空
        }
    }
}
